import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/api/v1/login',
    method: 'get',
    params: data
  })
}

export function logout() {
  return request({
    url: '/api/v1/logout',
    method: 'post'
  })
}

export function getAuthCode(params) {
  return request({
    url: '/api/v1/AuthCode',
    method: 'get',
    params: params
  })
}

export function getSessionID() {
  return request({
    url: '/api/v1/SessionId',
    method: 'get'
  })
}

// 获取用户列表(admin)
export function getUsers(params) {
  return request({
    url: '/api/v1/admin/users',
    method: 'get',
    params: params
  })
}

// 更新用户(admin)
export function updateUsers(data, user_id) {
  return request({
    url: '/api/v1/admin/users/' + user_id,
    method: 'put',
    data: data
  })
}

// 删除角色(admin)
export function deleteRole(role_id) {
  return request({
    url: '/api/v1/admin/roles/' + role_id,
    method: 'delete'
  })
}

// 创建角色(admin)
export function createRole(data) {
  return request({
    url: '/api/v1/admin/roles',
    method: 'post',
    data: data
  })
}
